package org.lintcode_Close.Stage1_Easy_50.O4字符串查找;

import java.util.HashSet;
import java.util.Set;

/**
 * @Auther: qingle
 * @Date: 2024/8/18-17:43
 * @Description:
 * @version: 1.0
 */
public class 最大字母 {

	public String largestLetter(String s) {
		// write your code here
		String s2 = s.toLowerCase();
		// Set<char> set = new HashSet<>();
		Set<Character> set = new HashSet<>();
		Set<Character> res = new HashSet<>();
		boolean find = false;
		for(int i = 0; i < s2.length(); i++) {
			boolean flag = set.add(s2.charAt(i));
			if (!flag && s.charAt(i) - s2.charAt(i) == -32) {
				res.add(s.charAt(i));
				find = true;
			}
			// if (s.charAt(i) - s2.charAt(i) == 32){
			// 	set.add(s.charAt(i));
			//     find = true;
			// }
		}

		if (find) {
			char max = 'A';
			for(char c : res) {
				if (c >= max) {
					max = c;
				}
			}
			return String.valueOf(max);
		}
		else {
			return "NO";
		}

	}


	public static void main(String[] args) {


		System.out.println(new 最大字母().largestLetter("abeCdEfG"));
	}

	}
